// const widget = createWidget()

//  Script.setWidget(widget)
// function createWidget() {
//   const widget = new ListWidget()
//   widget.addText('test')
//   return widget
// }


// function loadCode() {

// }

// updateCode()

// function updateCode() {

//   let files = FileManager.local()
//   const iCloudInUse = files.isFileStoredIniCloud(module.filename)
//   files = iCloudInUse ? FileManager.iCloud() : files
//   try {
//     const req = new Request("https://raw.githubusercontent.com/mzeryck/Widget-Blur/main/widget-blur.js")
//     const codeString = await req.loadString()
//     files.writeString(module.filename, codeString)
//     // message = "The code has been updated. If the script is open, close it for the change to take effect."
//   } catch {
//     // message = "The update failed. Please try again later."
//   } 
// }

// const url = ''
// const request = new Request(url)
// const dataString = await request.loadString()


// function generateImg() {

//   const webview = new WebView()
//   webview.loadHtml('<canvas>')
  
// }

import Pie from './pie.png'

class BaseWidget {

}

class CalendarWidget extends BaseWidget {

  renderSmall() {
   
  }

  renderMedium() {

  }

  renderLarge() {

  }

  renderExtraLarge() {
    
  }

}

const ctx = new DrawContext()

class Rect {

  constructor(left, top, width, height) {
    this.left = left
    this.top = top
    this.width = width
    this.height = height
  }
}

class Draw extends DrawContext {

  constructor() {
    this.ctx = new DrawContext()
    this.ctx.size = new Size(158, 158)
  }

  add(rect) {
    this.ctx.fillRect(rect.left, rect.top, rect.width, rect.height)
    this.ctx.setFillColor(Color.blue())
  }

  getImage() {
    return this.ctx.getImage()
  }

}
Draw.Rect = Rect

const draw = new Draw()

const rect = new Draw.Rect(0,0,100,100)

draw.add(rect)

const image = draw.getImage()



// 远程下载文件
// json配置列表，里面有可以动态添加配置文件

// 是否运行在小组件
if (config.runsInWidget) {
  if (confirm.widgetFamliy === 'small') {
    // const widget = new MyWidget()
    renderSmall()
  }
  if (confirm.widgetFamliy === 'media') {

  }
  if (confirm.widgetFamliy === 'large') {

  }
  // use to ipad widget
  if (confirm.widgetFamliy === 'extraLarge') {

  }

}
